package com.huifaapp.mall.activity.Homefragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.google.gson.Gson;
import com.huifaapp.mall.R;
import com.huifaapp.mall.bean.MessageThreeBean;
import com.squareup.okhttp.Request;
import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.callback.StringCallback;

public class MessageThreeActvity extends AppCompatActivity {

    private TextView tv_title,tv_message,tv_time;
    private MessageThreeBean.DataBean dataBean;
    private ImageView fanhui;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message_three_actvity);
        initView();
    }

    private void initView() {
        tv_title = (TextView) findViewById(R.id.three_title);
        tv_message = (TextView) findViewById(R.id.three_content);
        tv_time = (TextView) findViewById(R.id.three_time);
        fanhui = (ImageView) findViewById(R.id.threeeet_back);

        fanhui.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        Intent intent =getIntent();
        String id = intent.getStringExtra("parentId");
        OkHttpUtils.get().url("http://develop.jhjvip.cn:8080/mall/mobile/msg/info")
                .addParams("msgId",id)
                .build()
                .execute(new StringCallback() {
                    @Override
                    public void onError(Request request, Exception e) {

                    }

                    @Override
                    public void onResponse(String response) {
                        try {
                            Gson gson = new Gson();
                            MessageThreeBean messageThreeBean = gson.fromJson(response,MessageThreeBean.class);
                            dataBean = messageThreeBean.getData();
                            tv_title.setText(dataBean.getType());
                            tv_time.setText(dataBean.getCreateTime());
                            tv_message.setText(dataBean.getContent());
                        }catch (Exception e){
                            e.printStackTrace();
                        }

                    }
                });

    }
}
